﻿using System;
using System.ComponentModel;
using System.Data.Linq;
using System.Data.Linq.Mapping;

namespace Data.MappingClasses
{
    [TableAttribute(Name = "dbo.SchoolStatus")]
    public partial class SchoolStatus : INotifyPropertyChanging, INotifyPropertyChanged
    {

        private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);

        private short _idSchoolStatus;

        private string _nameSchoolStatus;

        private EntitySet<School> _Schools;

        #region Extensibility Method Definitions
        partial void OnLoaded();
        partial void OnValidate(ChangeAction action);
        partial void OnCreated();
        partial void OnidSchoolStatusChanging(short value);
        partial void OnidSchoolStatusChanged();
        partial void OnnameSchoolStatusChanging(string value);
        partial void OnnameSchoolStatusChanged();
        #endregion

        public SchoolStatus()
        {
            this._Schools = new EntitySet<School>(AttachSchools, DetachSchools);
            OnCreated();
        }

        [ColumnAttribute(Storage = "_idSchoolStatus", AutoSync = AutoSync.OnInsert, DbType = "SmallInt NOT NULL IDENTITY", IsPrimaryKey = true, IsDbGenerated = true)]
        public short idSchoolStatus
        {
            get
            {
                return this._idSchoolStatus;
            }
            set
            {
                if ((this._idSchoolStatus != value))
                {
                    this.OnidSchoolStatusChanging(value);
                    this.SendPropertyChanging();
                    this._idSchoolStatus = value;
                    this.SendPropertyChanged("idSchoolStatus");
                    this.OnidSchoolStatusChanged();
                }
            }
        }

        [ColumnAttribute(Storage = "_nameSchoolStatus", DbType = "VarChar(100) NOT NULL", CanBeNull = false)]
        public string nameSchoolStatus
        {
            get
            {
                return this._nameSchoolStatus;
            }
            set
            {
                if ((this._nameSchoolStatus != value))
                {
                    this.OnnameSchoolStatusChanging(value);
                    this.SendPropertyChanging();
                    this._nameSchoolStatus = value;
                    this.SendPropertyChanged("nameSchoolStatus");
                    this.OnnameSchoolStatusChanged();
                }
            }
        }

        [AssociationAttribute(Name = "SchoolStatus_School", Storage = "_Schools", ThisKey = "idSchoolStatus", OtherKey = "refSchoolStatus")]
        public EntitySet<School> Schools
        {
            get
            {
                return this._Schools;
            }
            set
            {
                this._Schools.Assign(value);
            }
        }

        public event PropertyChangingEventHandler PropertyChanging;

        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void SendPropertyChanging()
        {
            if ((this.PropertyChanging != null))
            {
                this.PropertyChanging(this, emptyChangingEventArgs);
            }
        }

        protected virtual void SendPropertyChanged(String propertyName)
        {
            if ((this.PropertyChanged != null))
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        private void AttachSchools(School entity)
        {
            this.SendPropertyChanging();
            entity.SchoolStatus = this;
        }

        private void DetachSchools(School entity)
        {
            this.SendPropertyChanging();
            entity.SchoolStatus = null;
        }
    }
}